<?php
    //html分页---num--数据数量
     function get_html_page_list($last=1,$limit=10,$num=0,$where=array(),$url="")
     {

        //搜索条件
        $str="";
        if($where)$str="&".ToUrlParams($where);



        $page_num=ceil($num/$limit);
        if($page_num<1)
        { 
            $page=array();
        }
        else
        {
            $page['first']['page']=1;
            $page['first']['href']=$url."&page=1".$str;
            $page['last']['page']= $page_num;
            $page['last']['href']=$url."&page=$page_num".$str;



           if($page_num>=$last)
           {
             
              //确定起始页
              if($last<5)
               {$beg_page=1;}
              else if($last%5!=0)
               $beg_page=floor($last/5)*5+1;
              else
              {
                  $beg_page=$last-4;
              }
            

             //每五个记录一个循环
             if($last-5>1)
             {

                   // $front=$last-1;
                    $front=$beg_page-5;
                   $page['front']['page']=$front;
                   $page['front']['href']=$url."&page=$front".$str;  
             }
             else $page['page']['front']=$page['first'];

             if($page_num-$last>1)
             {
                   // $after=$last+1;
                   $after=$beg_page+5;
                   $page['after']['page']=$after;
                   $page['after']['href']=$url."&page=$beg_page".$str;  
             }
             else $page['after']=$page['last'];

             //显示5页
            if($page_num>=$beg_page+4)
             {
                 $xs_num=5;
             }
             else //显示不足5页
             {
                $xs_num=$page_num-$beg_page+1;
             }

              for ($i=0; $i <$xs_num ; $i++) { 
                $page_index=$beg_page+$i;
                $pages[$i]['index']=0;
                if($page_index==$last)
                $pages[$i]['index']=1;
                $pages[$i]['page']=$page_index;
                $pages[$i]['href']=$url."&page=$page_index".$str;
            }

              $page['list']=$pages;
             
           } 
           else
           $page['list']=array();       
        }
  

       return $page;

     }

 

?>